#!/usr/env/bin python
# -*- coding: utf-8 -*-

# @Time    : 2020-09-16 10:58 上午
# @Author  : yangdy
# @File    : 2020-09-16.226.翻转二叉树
# @Software: PyCharmCE
from tools.my_methods import *


# Definition for a binary tree node.
class TreeNode:
    def __init__(self, x):
        self.val = x
        self.left = None
        self.right = None


class Solution:
    def invertTree(self, root: TreeNode) -> TreeNode:
        if not root:
            return root
        root.left, root.right = self.invertTree(root.right), self.invertTree(root.left)
        return root
